package com.dhl.fin.api.timer;

import com.dhl.fin.api.common.annotation.SchedulePlan;
import com.dhl.fin.api.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author CuiJianbo
 * @since 2025/4/6
 */
@Service
public class InterestJob {

    @Autowired
    private BankAccountService bankAccountService;

    @Autowired
    private BankCardMoneyReportService bankCardMoneyReportService;

    @Autowired
    private FixDepositService fixDepositService;

    @Autowired
    private DailyRateService dailyRateService;

    @Autowired
    private LendRecordService lendRecordService;

    @SchedulePlan(name = "计算上月的活期账户总利息", cron = "10 0 0 1 * *", env = "prod,uat")
    public void calculateMonthInterest() throws Exception {
        dailyRateService.calculateLastMonthInterest();
    }

    @SchedulePlan(name = "把当月的账户余额和利息归档到报表数据库里", cron = "20 0 1 * * *", env = "prod,uat")
    public void documentMoneyDataToReport() throws Exception {
        bankCardMoneyReportService.documentMoneyDataToReport();
    }

    @SchedulePlan(name = "计算每天的利息", cron = "30 1 0 * * *", env = "prod,uat")
    public void calculateDailyInterest() throws Exception {
        bankAccountService.calculateAllAccountInterest();
    }

    @SchedulePlan(name = "每天检查银行卡是否到期", cron = "10 2 0 * * *", env = "prod,uat")
    public void checkBankCardExpired() throws Exception {
        bankAccountService.checkBankCardIsExpired();
    }


    @SchedulePlan(name = "每天检查定期存款是否到期", cron = "15 3 0 * * *", env = "prod,uat")
    public void checkFixSaveMoneyExpired() throws Exception {
        fixDepositService.checkFixDepositExpired();
    }

    @SchedulePlan(name = "每天计算借出款的利息", cron = "35 3 0 * * *", env = "prod,uat")
    public void calculateDailyLendInterest() throws Exception {
        lendRecordService.calculateDailyLendInterest();
    }


}
